
using System.Linq;
using Abp.Authorization;
using Abp.Configuration.Startup;
using Abp.Localization;
using Abp.MultiTenancy;
using JYJ.AiYard.Authorization;

namespace JYJ.AiYard.PhoneBooks.Books.Authorization
{
    /// <summary>
    /// 权限配置都在这里。
    /// 给权限默认设置服务
    /// See <see cref="BooksPermissions" /> for all permission names. Book
    /// </summary>
    public class BooksAuthorizationProvider : AuthorizationProvider
    {
        private readonly bool _isMultiTenancyEnabled;

        public BooksAuthorizationProvider()
        {

        }

        public BooksAuthorizationProvider(bool isMultiTenancyEnabled)
        {
            _isMultiTenancyEnabled = isMultiTenancyEnabled;
        }

        public BooksAuthorizationProvider(IMultiTenancyConfig multiTenancyConfig)
        {
            _isMultiTenancyEnabled = multiTenancyConfig.IsEnabled;
        }

        public override void SetPermissions(IPermissionDefinitionContext context)
        {
            // 在这里配置了Book 的权限。
            ////var pages = context.GetPermissionOrNull(AppPermissions.Pages) ?? context.CreatePermission(AppPermissions.Pages, L("Pages"));

            ////var administration = pages.Children.FirstOrDefault(p => p.Name == AppPermissions.Pages_Administration) ?? pages.CreateChildPermission(AppPermissions.Pages_Administration, L("Administration"));

            ////var modulePermission = administration.CreateChildPermission(BooksPermissions.Node , L("Books"));
            ////var entityPermission = modulePermission.CreateChildPermission(BooksPermissions.BookPermissions.Node , L("Book"));
            ////entityPermission.CreateChildPermission(BooksPermissions.BookPermissions.Query, L("QueryBook"));
            ////entityPermission.CreateChildPermission(BooksPermissions.BookPermissions.Create, L("CreateBook"));
            ////entityPermission.CreateChildPermission(BooksPermissions.BookPermissions.Edit, L("EditBook"));
            ////entityPermission.CreateChildPermission(BooksPermissions.BookPermissions.Delete, L("DeleteBook"));
            ////entityPermission.CreateChildPermission(BooksPermissions.BookPermissions.BatchDelete, L("BatchDeleteBook"));
            ////entityPermission.CreateChildPermission(BooksPermissions.BookPermissions.ExportExcel, L("ExportExcelBook"));


        }

        private static ILocalizableString L(string name)
        {
            return new LocalizableString(name, AppConsts.LocalizationSourceName);
        }
		
				
		//// custom codes
		// TODO 自定义代码

		// TODO 自定义代码

		// TODO 自定义代码

		// TODO 自定义代码

		
		
		
		//// custom codes end
		
    }
}